package by.semerikov.statictic;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import by.semerikov.parts.Log;

public class StaticticByHour {
	
	private List<Log> list = new ArrayList<>();

	public StaticticByHour(List<Log> list) {
		this.setList(list);
	}
	
	public Map<String,List<Log>> getSortedByHour()
	{
		Map<String,List<Log>> result = new HashMap<String, List<Log>>();
		String key;
		for (Integer i = 0; i < 24; i++) {
			key = i.toString();
			List<Log> temp = new ArrayList<>();
			for (int j = 0; j < list.size(); j++) {
				if(key.equals( list.get(j).getDate().getHour().toString()))
				{
					temp.add(list.get(j));
				}
			}
			result.put(key, temp);
		}
		return result;
	}
	
	public Map<Integer,Integer> getStaticticByHour()
	{
		Map<Integer,Integer> result = new HashMap<Integer, Integer>();
		for (Integer i = 0; i < 24; i++) {
			Integer count = 0;
			for (int j = 0; j < list.size(); j++) {
				if(i.equals( list.get(j).getDate().getHour()))
				{
					count++;
				}
			}
			result.put(i, count);
		}
		return result;
	}

	public List<Log> getList() {
		return list;
	}

	public void setList(List<Log> list) {
		this.list = list;
	}
	
	

}
